﻿using M.WWHours.API.Command.WWHoursCommand;
using M.WWHours.Domain.Model;
using M.WWHours.Repository.WWHoursInterface;
using MediatR;

namespace M.WWHours.API.CommandHandlers.WWHoursCommandHandler
{
    /// <summary>
    /// 反填充工时命令处理器
    /// </summary>
    public class ReverseFillingWWHoursCommandHandler : IRequestHandler<ReverseFillingWWHoursCommand, WWorkingHours>
    {
        /// <summary>
        /// 工时工时仓储接口
        /// </summary>
        protected readonly IWWHoursRepository wWHoursRepository;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="wWHoursRepository">工时工时仓储接口</param>
        public ReverseFillingWWHoursCommandHandler(IWWHoursRepository wWHoursRepository)
        {
            this.wWHoursRepository = wWHoursRepository;
        }

        /// <summary>
        /// 处理反填充工时命令
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<WWorkingHours> Handle(ReverseFillingWWHoursCommand request, CancellationToken cancellationToken)
        {
            return await wWHoursRepository.GetModelsAsync(request.WWHoursId);
        }
    }
}
